/**
 * 
 */
package com.easidea.tim.entity.system;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;
import org.springside.core.dao.extend.Undeletable;

import com.easidea.tim.entity.BaseEntity;

/**
 * 地理信息
 * @author Harrison
 *
 */
@Entity(name="tim_base_geography")
@org.hibernate.annotations.Entity(dynamicInsert=true, dynamicUpdate=true)
@Cache(region="tim_base_geography",usage=CacheConcurrencyStrategy.READ_WRITE)
@Undeletable(status="deleted")
public class Geography extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3706266294765988819L;
	
	
	private String name;
	private Geography parentGeo;
	private List<Geography> sonList;
	
	
	/**
	 * @return the name
	 */
	@Column(name="name",nullable=false)
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the parentGeo
	 */
	@ManyToOne(cascade=CascadeType.MERGE,fetch=FetchType.EAGER)
	@JoinColumn(name="parent_id",nullable=true)
	public Geography getParentGeo() {
		return parentGeo;
	}
	/**
	 * @param parentGeo the parentGeo to set
	 */
	public void setParentGeo(Geography parentGeo) {
		this.parentGeo = parentGeo;
	}
	
	/**
	 * 
	 * @return
	 */
	@OneToMany(fetch=FetchType.EAGER, mappedBy="parentGeo", targetEntity=Geography.class)
	@Where(clause="deleted <> 1")
	public List<Geography> getSonList() {
		return sonList;
	}
	
	/**
	 * 
	 * @param sonList
	 */
	public void setSonList(List<Geography> sonList) {
		this.sonList = sonList;
	}

}
